package sourceagile.webservices;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sourceagile.server.subversionFileRepository.edit.EditClassDescription;

@SuppressWarnings("serial")
public class SaveClassDescriptionServlet extends HttpServlet {

	// http://localhost:8080/LiveSourceWebServices/SaveClassDescriptionService
	// ?repositoryURL=https://tictactoe4j.googlecode.com/svn/trunk
	// &username=alline.oliveira&password=bD8Km8se2rV9
	// &filePath=src/tictactoe/authentication/client/Login.java
	// &classDescription=Form%20to%20identify%20the%20name%20and%20the%20password%20of%20the%20player.
	// &classStatus=ToDo&classType=Feature

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws IOException {

		String repositoryURL = request.getParameter("repositoryURL");

		String username = request.getParameter("username");

		String password = request.getParameter("password");

		String filePath = request.getParameter("filePath");

		String classDescription = request.getParameter("classDescription");

		String classStatus = request.getParameter("classStatus");

		String classType = request.getParameter("classType");

		new EditClassDescription(repositoryURL, username, password, filePath,
				classDescription, classType, classStatus);

		String answer = GetCallback.getCallback(
				request.getParameter("callback"), "OK");

		response.getWriter().println(answer);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws IOException {

		String repositoryURL = request.getParameter("repositoryURL");

		String username = request.getParameter("username");

		String password = request.getParameter("password");

		String filePath = request.getParameter("filePath");

		String classDescription = request.getParameter("classDescription");

		String classStatus = request.getParameter("classStatus");

		String classType = request.getParameter("classType");

		new EditClassDescription(repositoryURL, username, password, filePath,
				classDescription, classType, classStatus);

		String answer = GetCallback.getCallback(
				request.getParameter("callback"), "OK");

		response.getWriter().println(answer);
	}
}
